/**
 * 定义静态路由表
 */
// @ 是 /src 路径的别名
import Navbar from '@/components/navbar'
import Tabbar from '@/components/tabbar'
import Home from '@/views/home'
import Category from '@/views/category'
import Cart from '@/views/cart'
import Mine from '@/views/mine'
import Login from '@/views/login'
import Detail from '@/views/detail'
import Confirm from '@/views/confirm'
import NotFound from '@/views/not-found'
import Shouhuodizhi from '@/views/shouhuodizhi'
import Querendingdan from '@/views/querendingdan'
import Search from '@/views/search'

const routes = [
  {
    path: '/',
    redirect: '/home', // 重定向
  },
  {
    path: '/home',
    components: {
      default: Home,
      footer: Tabbar,
    },
    meta: {
      title: '首页',
      icon: 'home-o',
      inTabbar: true,
    },
  },
  {
    path: '/category',
    components: {
      header: Navbar,
      default: Category,
      footer: Tabbar,
    },
    meta: {
      title: '分类',
      icon: 'apps-o',
      inTabbar: true,
    },
  },
  {
    path: '/cart',
    components: {
      header: Navbar,
      default: Cart,
      footer: Tabbar,
    },
    meta: {
      title: '购物车',
      icon: 'cart-o',
      inTabbar: true,
    },
  },
  {
    path: '/mine',
    components: {
      header: Navbar,
      default: Mine,
      footer: Tabbar,
    },
    meta: {
      title: '我的',
      icon: 'user-o',
      inTabbar: true,
    },
  },
  {
    path: '/login',
    components: {
      header: Navbar,
      default: Login,
    },
    meta: {
      title: '用户登录',
    },
  },
  {
    path: '/detail/:id?',
    name: 'detail',
    components: {
      header: Navbar,
      default: Detail,
    },
    meta: {
      title: '商品详情',
    },
  },
  {
    path: '/confirm',
    components: {
      header: Navbar,
      default: Confirm,
    },
    meta: {
      title: '订单结算',
      needPermission: true, // 访问当前页面需要权限
    },
  },
  {
    path: '/shouhuodizhi',
    components: {
      header: Navbar,
      default: Shouhuodizhi,
    },
    meta: {
      title: '选择收货地址',
    },
  },
  {
    path: '/querendingdan',
    components: {
      header: Navbar,
      default: Querendingdan,
    },
    meta: {
      title: '确认订单',
    },
  },
  {
    path: '/search',
    components: {
      header: Navbar,
      default: Search,
    },
    meta: {
      title: '搜索商品',
    },
  },
  {
    path: '*', // * 通配符，能够匹配所有路径，当前边的路径都没有匹配时，会进入该匹配项中，404
    components: {
      header: Navbar,
      default: NotFound,
    },
    meta: {
      title: 'NotFound',
    },
  },
]

export default routes
